<div class="d-flex justify-content-center">
  <div class="col-8">
    <form name="editForm" novalidate (ngSubmit)="save()" [formGroup]="editForm">
      <h2
        id="jhi-bank-account-heading"
        data-cy="BankAccountCreateUpdateHeading"
        jhiTranslate="jhipsterSampleApplicationApp.bankAccount.home.createOrEditLabel"
      >
        Create or edit a Bank Account
      </h2>

      <div>
        <jhi-alert-error />

        @if (editForm.controls.id.value !== null) {
          <div class="mb-3">
            <label class="form-label" for="field_id" jhiTranslate="jhipsterSampleApplicationApp.bankAccount.id">ID</label>
            <input type="number" class="form-control" name="id" id="field_id" data-cy="id" formControlName="id" [readonly]="true" />
          </div>
        }

        @let nameRef = editForm.get('name')!;
        <div class="mb-3">
          <label class="form-label" for="field_name" jhiTranslate="jhipsterSampleApplicationApp.bankAccount.name">Name</label>
          <input type="text" class="form-control" name="name" id="field_name" data-cy="name" formControlName="name" />
          @if (nameRef.invalid && (nameRef.dirty || nameRef.touched)) {
            <div>
              @if (editForm.get('name')?.errors?.required) {
                <small class="form-text text-danger" jhiTranslate="entity.validation.required">This field is required.</small>
              }
            </div>
          }
        </div>

        @let balanceRef = editForm.get('balance')!;
        <div class="mb-3">
          <label class="form-label" for="field_balance" jhiTranslate="jhipsterSampleApplicationApp.bankAccount.balance">Balance</label>
          <input type="number" class="form-control" name="balance" id="field_balance" data-cy="balance" formControlName="balance" />
          @if (balanceRef.invalid && (balanceRef.dirty || balanceRef.touched)) {
            <div>
              @if (editForm.get('balance')?.errors?.required) {
                <small class="form-text text-danger" jhiTranslate="entity.validation.required">This field is required.</small>
              }
              <small
                class="form-text text-danger"
                [hidden]="!editForm.get('balance')?.errors?.number"
                jhiTranslate="entity.validation.number"
                >This field should be a number.</small
              >
            </div>
          }
        </div>

        <div class="mb-3">
          <label class="form-label" for="field_user" jhiTranslate="jhipsterSampleApplicationApp.bankAccount.user">User</label>
          <select class="form-control" id="field_user" data-cy="user" name="user" formControlName="user" [compareWith]="compareUser">
            <option [ngValue]="null"></option>
            @for (userOption of usersSharedCollection(); track $index) {
              <option [ngValue]="userOption">{{ userOption.login }}</option>
            }
          </select>
        </div>
      </div>

      <div>
        <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" (click)="previousState()">
          <fa-icon icon="ban" />&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
        </button>

        <button
          type="submit"
          id="save-entity"
          data-cy="entityCreateSaveButton"
          [disabled]="editForm.invalid || isSaving"
          class="btn btn-primary"
        >
          <fa-icon icon="save" />&nbsp;<span jhiTranslate="entity.action.save">Save</span>
        </button>
      </div>
    </form>
  </div>
</div>
